package com.zazu.mycl.application.commands;

import com.zazu.mycl.application.AbstractTerminalCommand;
import com.zazu.mycl.application.CommandRunner;

public class EchoCommand extends AbstractTerminalCommand {

	public void run(String[] args, CommandRunner commandRunner, String commandLine, String outputFileName) 
	{
		this.setOutputFileName(outputFileName);
		
		args[0] = "";
		String echoLine = glueArray(args, " ");
		
		commandRunner.SetLine(echoLine);
		this.printToFile(echoLine);
	}
	
	public String glueArray(String[] arrayArg, String Glue)
	{
		StringBuilder finalString = new StringBuilder();
		
		for(String item : arrayArg)
		{
			if(!item.equals("") && !item.equals(" "))
			{
				finalString.append(item+Glue);
			}
		}
		
		return finalString.toString().trim();
	}
	
	public void runSubCommand(String[] args, String commandLine) {
		// none
	}

	public String getSignature() {
		// TODO Auto-generated method stub
		return "textToEcho";
	}
	
	public boolean isThreadable() {
		// TODO Auto-generated method stub
		return isThreadable;
	}

	private boolean isThreadable = true;
}
